import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    isCollapse: false,
    bread: [],
    defaultUrl:'',
  },
  mutations: {
    // 面包屑
    change(state,data) {
      // state.defaultUrl = data.index.slice(1,data.length)
      state.defaultUrl = data.title

      state.bread.push(data)
      state.bread = [...new Set(state.bread)]
      if (state.bread.length > 8) {
        state.bread.splice(0, 1)
      }
    },
    // 面包屑删除
    removeTag(state,data){
      state.bread.splice(data,1)
    },
    // 清空面包屑
    clearAll(state){
      state.bread=[]
    },
    // // 关闭其他面包屑
    clearIndex(state,data){
      let list = state.bread.filter(item=>{
        if('/'+item.index === data){
          return item
        }
      })
      state.bread=list
    },
    // 背景颜色改变
    changes(state,data){
      state.defaultUrl = data
    },
  },
  actions: {
  },
  modules: {
  }
})
